package com.blog.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.blog.pojo.Comment;
import com.blog.vojo.CommentVO;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Copyright (C), 2022
 * Author: 苏大大
 * Date: 2022-05-30 17:34
 * FileName: CommentMapper
 * Description: 博客评论数据层
 */
@Repository(value ="CommentMapper")
@Mapper
public interface CommentMapper extends BaseMapper<Comment> {
    /**
     * 将根节点评论封装到list
     * @return
     */
//    @Select("SELECT u.nickname, u.avatar, c.comment_id, c.uid, c.content, c.create_time, c.blog_id, c.parent_comment_id " +
//            "FROM comment c, user u " +
//            "WHERE c.uid = u.uid AND c.blog_id = #{blogId} AND c.parent_comment_id = -1 ")
    List<CommentVO> selectRootList(Long blogId);

    /**
     * 将不是根节点评论封装到list
     * @return
     */
//    @Select("SELECT u.nickname, u.avatar, c.comment_id, c.uid, c.content, c.create_time, c.blog_id, c.parent_comment_id, c.reply_uid, uu.nickname as reply_nickname " +
//            "FROM comment c, user u, user uu " +
//            "WHERE c.uid = u.uid AND c.blog_id = #{blogId} AND c.parent_comment_id != -1 AND c.reply_uid = uu.uid")
    List<CommentVO> selectChildList(Long blogId);

}
